<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="navUri" content="<s:url action="list" namespace="/admin/shop" />">
<title><s:if test="%{addOperation}">新增</s:if>
	<s:else>编辑</s:else>商铺</title>
</head>
<body>

<script type="text/javascript">
    var form = null;
    var formValidator = null;
    
    $(document).ready(function(){
    	$("#title").focus();
    	
        form = $("#frm");
        formValidator = form.validate({
            rules: {
                "shop.name": {
                    required: true,
                    rangelength: [2, 200]
                }
            },
           messages: { 
        	    "shop.name": {
                    required: "请输入名称", 
                    rangelength: jQuery.format("标题长度介于 {0} 和 {1} 之间的字符串")
               }
            }
        });
        
        $("#frm :reset").click(function() {
            formValidator.resetForm();
        });
        
    });
    </script>       

    <div class="col-md-12">
      <!-- BEGIN EXAMPLE TABLE PORTLET-->
      <div class="portlet">
         <div class="portlet-title">
            <div class="caption"><i class="icon-edit"></i><s:if test="%{addOperation}">新增</s:if><s:else>编辑</s:else>商铺信息</div>
         </div>
         
         <s:form id="frm" action="save" namespace="/admin/shop" method="post"  enctype="multipart/form-data" cssClass="form-horizontal">
	         <div class="portlet-body">
	             	<div class="input-group">
                    	<label class="col-md-3 control-label">名称：</label>
                        <s:textfield name="shop.name" cssClass="form-control" cssStyle="width: 400px" maxlength="100" />
                    </div>
                    
                    <div class="input-group">
                    	<label class="col-md-3 control-label" style="float: left;">图片：</label>
	                    <div class="fileupload fileupload-new" style="float: left;" data-provides="fileupload">
	                        <div class="fileupload-new thumbnail" style="width: 200px; height: 150px;">
	                           <img src="<s:property value="getShopImage(shop.thumbnail)" />" 
	                           		onerror="this.src='<s:url value="/admin/assets/img/no_image.png" />';" 
	                           		alt="<s:property value="shop.name" />" title="<s:property value="shop.name" />" />
	                        </div>
	                        <div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 200px; max-height: 150px; line-height: 10px;"></div>
	                        <div>
	                           <span class="btn btn-default btn-file">
	                           <span class="fileupload-new"><i class="icon-paper-clip"></i> 添加图片</span>
	                           <span class="fileupload-exists"><i class="icon-undo"></i> 更改</span>
	                           <s:file name="thumbnail" cssClass="default" />
	                           </span>
	                           <a href="#" class="btn btn-danger fileupload-exists" data-dismiss="fileupload"><i class="icon-trash"></i> 删除</a>
	                        </div>
                        </div>
	                    <s:hidden name="oldThumbnail" value="${shop.thumbnail}" />
                    </div>
                    
	             	<div class="input-group">
                    	<label class="col-md-3 control-label">简介：</label>
                        <s:textarea name="shop.summary" cssClass="form-control" cssStyle="width: 400px; height:100px;" />
                    </div>
                    
	             	<div class="input-group">
                    	<label class="col-md-3 control-label" style="float: left;">内容：</label>
                    	<input id="contentField" type="text" value="<s:property value="shop.content" />" style="display: none;">
                    	<div id="htmlEditor" style="width:650px;height:300px; float: right;display: block;"></div>
		                <script type="text/javascript">
		                    var editor = new UE.ui.Editor({
		                        textarea : "shop.content",
		
		                    });
		                    editor.render("htmlEditor");
		                    editor.ready(function() {
		                        //需要ready后执行，否则可能报错
		                        editor.setContent($("#contentField").val());
		                    });
		                </script>
                    </div>
	         </div>
         
                <s:include value="/WEB-INF/jsp/admin/form-button-bar.jsp"></s:include>
         </s:form>
      </div>
      <!-- END EXAMPLE TABLE PORTLET-->
   </div>
</body>
</html>